package com.marcinklos.filipides;

import java.util.EnumSet;
import java.util.Set;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

@PersistenceCapable(detachable="true")
public class User {
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key userId;
    @Persistent private String googleUserId;
    @Persistent private String nickName;
    @Persistent private String email;
    @Persistent private Set<UserRole> roles;
	
	/**
	 * @param googleUserId
	 * @param nickName
	 * @param email
	 */
	public User(String googleUserId, String nickName, String email) {
		this.googleUserId = googleUserId;
		this.nickName = nickName;
		this.email = email;
		this.roles = EnumSet.of(UserRole.ROLE_NEW_USER);
	}

	public String getUserId() {
		return googleUserId.toString();
	}

	/**
	 * @return the roles
	 */
	public Set<UserRole> getRoles() {
		return roles;
	}

	/**
	 * @param roles the roles to set
	 */
	public void setRoles(Set<UserRole> roles) {
		this.roles = roles;
	}

	/**
	 * @return the googleUserId
	 */
	public String getGoogleUserId() {
		return googleUserId;
	}

	/**
	 * @return the nickName
	 */
	public String getNickName() {
		return nickName;
	}

	/**
	 * @return the email
	 */
	public String getEmail() {
		return email;
	}
}
